/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.cheetah.youbet.gui;

import java.awt.Color;
import java.awt.event.KeyEvent;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JLabel;
import javax.swing.JSlider;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableColumn;
import org.cheetah.youbet.ContextSpringFactory;
import org.cheetah.youbet.entities.Incontro;
import org.cheetah.youbet.entities.Palinsesto;
import org.cheetah.youbet.entities.PercentualeSingoliEsiti;
import org.cheetah.youbet.entities.PercentualeSingoliEsitiPK;
import org.cheetah.youbet.gui.model.IncontroTableModel;
import org.cheetah.youbet.gui.model.JsonTableModel;
import org.cheetah.youbet.gui.model.PalinsestoTableModel;
import org.cheetah.youbet.gui.model.PoissonTableModel;
import org.cheetah.youbet.gui.popupmenu.PoissonPopupMenu;
import org.cheetah.youbet.service.GenericService;
import org.cheetah.youbet.service.IncontroService;
import org.cheetah.youbet.service.PercentualeSingoliEsitiService;
import org.cheetah.youbet.util.helper.IncontroHelper;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.data.domain.Page;

/**
 *
 * @author edoardo
 */
public class PoissonDialog extends javax.swing.JFrame {

    private List<Palinsesto> palinsestos;

    /**
     * Creates new form PoissonFrame
     */
    public PoissonDialog(List<Palinsesto> palinsestos) {
        this.palinsestos = palinsestos;
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        mainPanel = new javax.swing.JPanel();
        splitPane = new javax.swing.JSplitPane();
        palinsestoScrollPane = new javax.swing.JScrollPane();
        palinsestoTable = new javax.swing.JTable();
        jSplitPane1 = new javax.swing.JSplitPane();
        panelRiepilogo = new javax.swing.JPanel();
        tabRiepilogoPoisson = new javax.swing.JTabbedPane();
        panel1X2 = new javax.swing.JPanel();
        label_1 = new javax.swing.JLabel();
        labelPerc_1 = new javax.swing.JLabel();
        label_X = new javax.swing.JLabel();
        labelPerc_X = new javax.swing.JLabel();
        label_2 = new javax.swing.JLabel();
        labelPerc_2 = new javax.swing.JLabel();
        label_1X = new javax.swing.JLabel();
        labelPerc_1X = new javax.swing.JLabel();
        label_X2 = new javax.swing.JLabel();
        labelPerc_X2 = new javax.swing.JLabel();
        label_12 = new javax.swing.JLabel();
        labelPerc_12 = new javax.swing.JLabel();
        label_Gol = new javax.swing.JLabel();
        labelPerc_Gol = new javax.swing.JLabel();
        label_NoGol = new javax.swing.JLabel();
        labelPerc_NoGol = new javax.swing.JLabel();
        label_Pari = new javax.swing.JLabel();
        labelPerc_Pari = new javax.swing.JLabel();
        label_Dispari = new javax.swing.JLabel();
        labelPerc_Dispari = new javax.swing.JLabel();
        label_ov15 = new javax.swing.JLabel();
        labelPerc_ov15 = new javax.swing.JLabel();
        label_un15 = new javax.swing.JLabel();
        labelPerc_un15 = new javax.swing.JLabel();
        label_ov25 = new javax.swing.JLabel();
        labelPerc_ov25 = new javax.swing.JLabel();
        label_un25 = new javax.swing.JLabel();
        labelPerc_un25 = new javax.swing.JLabel();
        label_ov35 = new javax.swing.JLabel();
        labelPerc_ov35 = new javax.swing.JLabel();
        label_un35 = new javax.swing.JLabel();
        labelPerc_un35 = new javax.swing.JLabel();
        label_ov45 = new javax.swing.JLabel();
        labelPerc_ov45 = new javax.swing.JLabel();
        label_un45 = new javax.swing.JLabel();
        labelPerc_un45 = new javax.swing.JLabel();
        panelStatsHomeTeam = new javax.swing.JPanel();
        scrollPaneStatsHomeTeam = new javax.swing.JScrollPane();
        tableIncontriHomeTeam = new IncontroTable();
        sliderNumPartiteHome = new javax.swing.JSlider();
        panelStatsAwayTeam = new javax.swing.JPanel();
        scrollPaneStatsAwayTeam = new javax.swing.JScrollPane();
        tableIncontriAwayTeam = new IncontroTable();
        sliderNumPartiteAway = new javax.swing.JSlider();
        panelPoissonScrollPane = new javax.swing.JPanel();
        poissonScrollPane = new javax.swing.JScrollPane();
        poissonTable = new javax.swing.JTable();
        topPanel = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        filtraPercentualeSlider = new javax.swing.JSlider();
        filtraPercentualeLabel = new javax.swing.JLabel();
        panelRiepilogoRisultati = new javax.swing.JPanel();
        splitRiepilogo = new javax.swing.JSplitPane();
        tabRiepilogoHomeTeam = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        scrollPaneRiepilogoSqHome = new javax.swing.JScrollPane();
        tableRiepilogoSqHome = new javax.swing.JTable();
        tabRiepilogoAwayTeam = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        scrollPaneRiepilogoSqAway = new javax.swing.JScrollPane();
        tableRiepilogoSqAway = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                formKeyPressed(evt);
            }
        });

        mainPanel.setLayout(new java.awt.GridBagLayout());

        splitPane.setResizeWeight(0.5);

        palinsestoTable.setModel(new PalinsestoTableModel(this.palinsestos,
            new PalinsestoTableModel.PalinsestoColumn[]{PalinsestoTableModel.PalinsestoColumn.ID_PALINSESTO,
                PalinsestoTableModel.PalinsestoColumn.ID_AVVENIMENTO,PalinsestoTableModel.PalinsestoColumn.DESCRIZIONE}));
    palinsestoTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    palinsestoTable.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            palinsestoTableMouseClicked(evt);
        }
    });
    palinsestoTable.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyReleased(java.awt.event.KeyEvent evt) {
            palinsestoTableKeyReleased(evt);
        }
    });
    palinsestoScrollPane.setViewportView(palinsestoTable);

    splitPane.setLeftComponent(palinsestoScrollPane);

    jSplitPane1.setDividerLocation(0.75);
    jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

    panelRiepilogo.setLayout(new java.awt.GridBagLayout());

    panel1X2.setLayout(new java.awt.GridBagLayout());

    label_1.setText("1");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.ipadx = 5;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(label_1, gridBagConstraints);

    labelPerc_1.setText("---");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.ipadx = 15;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(labelPerc_1, gridBagConstraints);

    label_X.setText("X");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.ipadx = 5;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(label_X, gridBagConstraints);

    labelPerc_X.setText("---");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.ipadx = 15;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(labelPerc_X, gridBagConstraints);

    label_2.setText("2");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.ipadx = 5;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(label_2, gridBagConstraints);

    labelPerc_2.setText("---");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.ipadx = 15;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(labelPerc_2, gridBagConstraints);

    label_1X.setText("1X");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.ipadx = 15;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(label_1X, gridBagConstraints);

    labelPerc_1X.setText("---");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.ipadx = 5;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(labelPerc_1X, gridBagConstraints);

    label_X2.setText("X2");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.ipadx = 15;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(label_X2, gridBagConstraints);

    labelPerc_X2.setText("---");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.ipadx = 5;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(labelPerc_X2, gridBagConstraints);

    label_12.setText("12");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.ipadx = 15;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(label_12, gridBagConstraints);

    labelPerc_12.setText("---");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.ipadx = 5;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(labelPerc_12, gridBagConstraints);

    label_Gol.setText("Gol");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.ipadx = 5;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(label_Gol, gridBagConstraints);

    labelPerc_Gol.setText("---");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.ipadx = 15;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(labelPerc_Gol, gridBagConstraints);

    label_NoGol.setText("No Gol");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.ipadx = 5;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(label_NoGol, gridBagConstraints);

    labelPerc_NoGol.setText("---");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.ipadx = 15;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(labelPerc_NoGol, gridBagConstraints);

    label_Pari.setText("Pari");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.ipadx = 5;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(label_Pari, gridBagConstraints);

    labelPerc_Pari.setText("---");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.ipadx = 15;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(labelPerc_Pari, gridBagConstraints);

    label_Dispari.setText("Dispari");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.ipadx = 5;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(label_Dispari, gridBagConstraints);

    labelPerc_Dispari.setText("---");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.ipadx = 15;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(labelPerc_Dispari, gridBagConstraints);

    label_ov15.setText("Over1.5");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 5;
    gridBagConstraints.ipadx = 5;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(label_ov15, gridBagConstraints);

    labelPerc_ov15.setText("---");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 5;
    gridBagConstraints.ipadx = 15;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(labelPerc_ov15, gridBagConstraints);

    label_un15.setText("Under 1.5");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 5;
    gridBagConstraints.ipadx = 15;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(label_un15, gridBagConstraints);

    labelPerc_un15.setText("---");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 5;
    gridBagConstraints.ipadx = 5;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(labelPerc_un15, gridBagConstraints);

    label_ov25.setText("Over2.5");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 6;
    gridBagConstraints.ipadx = 5;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(label_ov25, gridBagConstraints);

    labelPerc_ov25.setText("---");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 6;
    gridBagConstraints.ipadx = 15;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(labelPerc_ov25, gridBagConstraints);

    label_un25.setText("Under 2.5");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 6;
    gridBagConstraints.ipadx = 15;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(label_un25, gridBagConstraints);

    labelPerc_un25.setText("---");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 6;
    gridBagConstraints.ipadx = 5;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(labelPerc_un25, gridBagConstraints);

    label_ov35.setText("Over3.5");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 7;
    gridBagConstraints.ipadx = 5;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(label_ov35, gridBagConstraints);

    labelPerc_ov35.setText("---");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 7;
    gridBagConstraints.ipadx = 15;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(labelPerc_ov35, gridBagConstraints);

    label_un35.setText("Under 3.5");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 7;
    gridBagConstraints.ipadx = 15;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(label_un35, gridBagConstraints);

    labelPerc_un35.setText("---");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 7;
    gridBagConstraints.ipadx = 5;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(labelPerc_un35, gridBagConstraints);

    label_ov45.setText("Over4.5");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 8;
    gridBagConstraints.ipadx = 5;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(label_ov45, gridBagConstraints);

    labelPerc_ov45.setText("---");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 8;
    gridBagConstraints.ipadx = 15;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(labelPerc_ov45, gridBagConstraints);

    label_un45.setText("Under 4.5");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 8;
    gridBagConstraints.ipadx = 15;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(label_un45, gridBagConstraints);

    labelPerc_un45.setText("---");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 8;
    gridBagConstraints.ipadx = 5;
    gridBagConstraints.ipady = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    panel1X2.add(labelPerc_un45, gridBagConstraints);

    tabRiepilogoPoisson.addTab("Esito 1X2", panel1X2);

    panelStatsHomeTeam.setLayout(new java.awt.GridBagLayout());

    tableIncontriHomeTeam.setModel(new IncontroTableModel(new ArrayList<Incontro>())
    );
    tableIncontriHomeTeam.setRowSelectionAllowed(false);
    scrollPaneStatsHomeTeam.setViewportView(tableIncontriHomeTeam);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    panelStatsHomeTeam.add(scrollPaneStatsHomeTeam, gridBagConstraints);

    sliderNumPartiteHome.setMajorTickSpacing(1);
    sliderNumPartiteHome.setMaximum(15);
    sliderNumPartiteHome.setMinimum(9);
    sliderNumPartiteHome.setMinorTickSpacing(1);
    sliderNumPartiteHome.setPaintLabels(true);
    sliderNumPartiteHome.setPaintTicks(true);
    sliderNumPartiteHome.setToolTipText("");
    sliderNumPartiteHome.setValue(9);
    sliderNumPartiteHome.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
    sliderNumPartiteHome.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            sliderNumPartiteHomeStateChanged(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.weightx = 1.0;
    panelStatsHomeTeam.add(sliderNumPartiteHome, gridBagConstraints);

    tabRiepilogoPoisson.addTab("SQUADRA CASA", panelStatsHomeTeam);

    panelStatsAwayTeam.setLayout(new java.awt.GridBagLayout());

    tableIncontriAwayTeam.setModel(new IncontroTableModel(new ArrayList<Incontro>())
    );
    tableIncontriAwayTeam.setRowSelectionAllowed(false);
    scrollPaneStatsAwayTeam.setViewportView(tableIncontriAwayTeam);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    panelStatsAwayTeam.add(scrollPaneStatsAwayTeam, gridBagConstraints);

    sliderNumPartiteAway.setMajorTickSpacing(1);
    sliderNumPartiteAway.setMaximum(15);
    sliderNumPartiteAway.setMinimum(9);
    sliderNumPartiteAway.setMinorTickSpacing(1);
    sliderNumPartiteAway.setPaintLabels(true);
    sliderNumPartiteAway.setPaintTicks(true);
    sliderNumPartiteAway.setValue(9);
    sliderNumPartiteAway.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
    sliderNumPartiteAway.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            sliderNumPartiteAwayStateChanged(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.weightx = 1.0;
    panelStatsAwayTeam.add(sliderNumPartiteAway, gridBagConstraints);

    tabRiepilogoPoisson.addTab("SQUADRA OSPITE", panelStatsAwayTeam);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    panelRiepilogo.add(tabRiepilogoPoisson, gridBagConstraints);
    tabRiepilogoPoisson.getAccessibleContext().setAccessibleName("Esito 1X2");

    jSplitPane1.setRightComponent(panelRiepilogo);

    panelPoissonScrollPane.setLayout(new java.awt.GridBagLayout());

    poissonTable.setModel(new javax.swing.table.DefaultTableModel(
        new Object [][] {
        },
        new String [] {
        }
    ));
    poissonScrollPane.setViewportView(poissonTable);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    panelPoissonScrollPane.add(poissonScrollPane, gridBagConstraints);

    jSplitPane1.setLeftComponent(panelPoissonScrollPane);

    splitPane.setRightComponent(jSplitPane1);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    mainPanel.add(splitPane, gridBagConstraints);

    jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel1.setText("Percentuale");
    topPanel.add(jLabel1);

    filtraPercentualeSlider.setMajorTickSpacing(5);
    filtraPercentualeSlider.setMaximum(15);
    filtraPercentualeSlider.setPaintLabels(true);
    filtraPercentualeSlider.setPaintTicks(true);
    filtraPercentualeSlider.setValue(0);
    filtraPercentualeSlider.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            filtraPercentualeSliderStateChanged(evt);
        }
    });
    topPanel.add(filtraPercentualeSlider);
    //filtraPercentualeSlider.setLabelTable(filtraPercentualeSlider.createStandardLabels(1));
    filtraPercentualeSlider.setPaintTicks(true);
    filtraPercentualeSlider.setPaintLabels(true);

    filtraPercentualeLabel.setText(Integer.toString(filtraPercentualeSlider.getValue()));
    topPanel.add(filtraPercentualeLabel);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 0.5;
    mainPanel.add(topPanel, gridBagConstraints);

    panelRiepilogoRisultati.setLayout(new java.awt.GridBagLayout());

    splitRiepilogo.setDividerSize(100);
    splitRiepilogo.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

    jPanel1.setLayout(new java.awt.GridBagLayout());

    tableRiepilogoSqHome.setModel(new javax.swing.table.DefaultTableModel(
        new Object [][] {
        },
        new String [] {
        }
    ));
    scrollPaneRiepilogoSqHome.setViewportView(tableRiepilogoSqHome);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    jPanel1.add(scrollPaneRiepilogoSqHome, gridBagConstraints);

    tabRiepilogoHomeTeam.addTab("riep-sq1", jPanel1);

    splitRiepilogo.setLeftComponent(tabRiepilogoHomeTeam);

    jPanel2.setLayout(new java.awt.GridBagLayout());

    tableRiepilogoSqAway.setModel(new javax.swing.table.DefaultTableModel(
        new Object [][] {
        },
        new String [] {
        }
    ));
    scrollPaneRiepilogoSqAway.setViewportView(tableRiepilogoSqAway);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    jPanel2.add(scrollPaneRiepilogoSqAway, gridBagConstraints);

    tabRiepilogoAwayTeam.addTab("riep-sq2", jPanel2);

    splitRiepilogo.setRightComponent(tabRiepilogoAwayTeam);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    panelRiepilogoRisultati.add(splitRiepilogo, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 0.5;
    mainPanel.add(panelRiepilogoRisultati, gridBagConstraints);

    getContentPane().add(mainPanel, java.awt.BorderLayout.CENTER);

    pack();
    }// </editor-fold>//GEN-END:initComponents

    private void palinsestoTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_palinsestoTableMouseClicked
        if (SwingUtilities.isLeftMouseButton(evt)) {
            try {

                palinesestoTableEvents();

            } catch (BeansException ex) {
                Logger.getLogger(PoissonDialog.class.getName()).log(Level.SEVERE, null, ex);
            } catch (SQLException ex) {
                Logger.getLogger(PoissonDialog.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(PoissonDialog.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        if (SwingUtilities.isRightMouseButton(evt) && !evt.isPopupTrigger()) {
            int row = palinsestoTable.rowAtPoint(evt.getPoint());
            palinsestoTable.getSelectionModel().addSelectionInterval(row, row);

            new PoissonPopupMenu(palinsestos.toArray(new Palinsesto[0])[row]).show(evt.getComponent(), evt.getX(), evt.getY());
        }
    }

    private void palinesestoTableEvents() throws BeansException, IOException, SQLException {
        sliderNumPartiteAway.setValue(9);
        sliderNumPartiteHome.setValue(9);
        changePalinsestoTableData();
        changeSplitRiepilogoTableData();
        
        calcolaMatch(getPalinsestoRowSelected(palinsestoTable));
    }

    private void changePalinsestoTableData() throws BeansException, SQLException, IOException {
        Palinsesto palinsestoSelected = getPalinsestoRowSelected(palinsestoTable);
        ApplicationContext ctx = ContextSpringFactory.getInstance().getContext();
        PoissonTableModel model = ctx.getBean(PoissonTableModel.class);
        GenericService serv = ctx.getBean(GenericService.class);
        initPoissonModel(model, palinsestoSelected);

        model.loadDataPercentualeGreaterThan(palinsestoSelected, filtraPercentualeSlider.getValue());
        poissonTable.setModel(model);
        JTableHeader header = poissonTable.getTableHeader();
        if (header.getColumnModel().getColumnCount() > 0) {
            TableColumn tableColumnHome = header.getColumnModel().getColumn(0);
            TableColumn tableColumnAway = header.getColumnModel().getColumn(1);
            tableColumnHome.setHeaderValue(palinsestoSelected.getHomeTeam());
            tableColumnAway.setHeaderValue(palinsestoSelected.getAwayTeam());
            header.repaint();
        }
        model.fireTableDataChanged();
    }

    private void calcolaMatch(Palinsesto palinsestoSelected) throws SQLException, IOException {
        PercentualeSingoliEsitiService serv = ContextSpringFactory.getInstance().getContext().getBean(PercentualeSingoliEsitiService.class);
        PercentualeSingoliEsiti pse = serv.findByPk(
                new PercentualeSingoliEsitiPK(
                        palinsestoSelected.getPalinsestoPK().getIdPalinsesto(),
                        palinsestoSelected.getPalinsestoPK().getIdAvvenimento()));
        labelPerc_1.setText(Double.toString(pse.getVittoriaCasa()));
        setLabelColor(pse.getVittoriaCasa(),labelPerc_1);
        
        labelPerc_X.setText(Double.toString(pse.getPareggio()));
        setLabelColor(pse.getPareggio(),labelPerc_X);
        
        labelPerc_2.setText(Double.toString(pse.getVittoriaFuori()));
        setLabelColor(pse.getVittoriaFuori(),labelPerc_2);
        
        labelPerc_12.setText(Double.toString(pse.getDoppiaChanceInOut()));
        setLabelColor(pse.getDoppiaChanceInOut(),labelPerc_12);
        
        labelPerc_X2.setText(Double.toString(pse.getDoppiaChanceOut()));
        setLabelColor(pse.getDoppiaChanceOut(),labelPerc_X2);
        
        labelPerc_1X.setText(Double.toString(pse.getDoppiaChanceIn()));
        setLabelColor(pse.getDoppiaChanceIn(),labelPerc_1X);
        
        labelPerc_Dispari.setText(Double.toString(pse.getDispari()));
        setLabelColor(pse.getDispari(),labelPerc_Dispari);
        
        labelPerc_Pari.setText(Double.toString(pse.getPari()));
        setLabelColor(pse.getPari(),labelPerc_Pari);
        
        labelPerc_Gol.setText(Double.toString(pse.getGol()));
        setLabelColor(pse.getGol(),labelPerc_Gol);
        
        labelPerc_NoGol.setText(Double.toString(pse.getNoGol()));
        setLabelColor(pse.getNoGol(),labelPerc_NoGol);
        
        labelPerc_NoGol.setText(Double.toString(pse.getNoGol()));
        setLabelColor(pse.getNoGol(),labelPerc_NoGol);
        
        labelPerc_ov15.setText(Double.toString(pse.getOverUnoCinque()));
        setLabelColor(pse.getOverUnoCinque(),labelPerc_ov15);
        
        labelPerc_un15.setText(Double.toString(pse.getUnderUnoCinque()));
        setLabelColor(pse.getUnderUnoCinque(),labelPerc_un15);
        
        labelPerc_ov25.setText(Double.toString(pse.getOverDueCinque()));
        setLabelColor(pse.getOverDueCinque(),labelPerc_ov25);
        
        labelPerc_un25.setText(Double.toString(pse.getUnderDueCinque()));
        setLabelColor(pse.getUnderDueCinque(),labelPerc_un25);
        
        labelPerc_ov35.setText(Double.toString(pse.getOverTreCinque()));
        setLabelColor(pse.getOverTreCinque(),labelPerc_ov35);
        
        labelPerc_un35.setText(Double.toString(pse.getUnderTreCinque()));
        setLabelColor(pse.getUnderTreCinque(),labelPerc_un35);
        
        labelPerc_ov45.setText(Double.toString(pse.getOverQuattroCinque()));
        setLabelColor(pse.getOverQuattroCinque(),labelPerc_ov45);
        
        labelPerc_un45.setText(Double.toString(pse.getUnderQuattroCinque()));
        setLabelColor(pse.getUnderQuattroCinque(),labelPerc_un45);

        loadStatsTeam(palinsestoSelected, 1, tableIncontriHomeTeam, palinsestoSelected.getHomeTeam(), 9);
        loadStatsTeam(palinsestoSelected, 2, tableIncontriAwayTeam, palinsestoSelected.getAwayTeam(), 9);

    }

    private void setLabelColor(double value,JLabel label) {
        if(value>=80.0d){
            label.setForeground(Color.RED);
        }else{
            label.setForeground(Color.BLACK);
            
        }
    }

    private void loadStatsTeam(Palinsesto palinsesto, int indexTab, JTable table, String squadra, int maxMatchNumber) {
        ApplicationContext ctx = ContextSpringFactory.getInstance().getContext();
        IncontroService incontroService = ctx.getBean(IncontroService.class);
        tabRiepilogoPoisson.setTitleAt(indexTab, squadra);
        ((IncontroTable) table).setTeam(squadra);
        Page<Incontro> incontros = incontroService.findIncontroByTeam(palinsesto.getIdManifestazione().getDescrizioneLunga(), squadra, maxMatchNumber);

        IncontroTableModel model = new IncontroTableModel(incontros.getContent(), new IncontroTableModel.IncontroColumn[]{
            IncontroTableModel.IncontroColumn.DATA_EVENTO,
            IncontroTableModel.IncontroColumn.HOME_TEAM,
            IncontroTableModel.IncontroColumn.AWAY_TEAM,
            IncontroTableModel.IncontroColumn.GOL_HOME,
            IncontroTableModel.IncontroColumn.GOL_AWAY,
            IncontroTableModel.IncontroColumn.SEGNO_FINALE
        });
//        model.setIncontros(incontros.getContent());
        table.setModel(model);;
        model.fireTableDataChanged();

    }

    private void initPoissonModel(PoissonTableModel model, Palinsesto palinsestoSelected) {
        model.setPalinsestoSelected(palinsestoSelected);
        model.setVisibleColumns(new PoissonTableModel.PoissonColumn[]{
            PoissonTableModel.PoissonColumn.GOL_HOME,
            PoissonTableModel.PoissonColumn.GOL_AWAY,
            PoissonTableModel.PoissonColumn.PERCENTUALE
        });

    }//GEN-LAST:event_palinsestoTableMouseClicked

    private Palinsesto getPalinsestoRowSelected(JTable table) {
        Palinsesto palinsestoSelected = palinsestos.toArray(new Palinsesto[0])[table.getSelectedRow()];
        return palinsestoSelected;
    }

    private void filtraPercentualeSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_filtraPercentualeSliderStateChanged
        JSlider slider = (JSlider) evt.getSource();
        filtraPercentualeLabel.setText(Integer.toString(slider.getValue()));
        if (palinsestoTable.getSelectedRow() != -1) {
            try {
                //            Palinsesto p = getPalinsestoRowSelected(palinsestoTable);
//            PoissonTableModel model = ContextSpringFactory.getInstance().getContext().getBean(PoissonTableModel.class);
//            initPoissonModel(model, p);
//            model.loadDataPercentualeGreaterThan(p,slider.getValue());
//            poissonTable.setModel(model);
//            model.fireTableDataChanged();
                changePalinsestoTableData();
            } catch (BeansException ex) {

                Logger.getLogger(PoissonDialog.class.getName()).log(Level.SEVERE, null, ex);
            } catch (SQLException ex) {
                Logger.getLogger(PoissonDialog.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(PoissonDialog.class.getName()).log(Level.SEVERE, null, ex);
            }
        }


    }//GEN-LAST:event_filtraPercentualeSliderStateChanged

    private void palinsestoTableKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_palinsestoTableKeyReleased
        if (evt.getKeyCode() == KeyEvent.VK_UP || evt.getKeyCode() == KeyEvent.VK_DOWN) {
            try {
                palinesestoTableEvents();
            } catch (BeansException ex) {
                Logger.getLogger(PoissonDialog.class.getName()).log(Level.SEVERE, null, ex);
            } catch (SQLException ex) {
                Logger.getLogger(PoissonDialog.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(PoissonDialog.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }//GEN-LAST:event_palinsestoTableKeyReleased

    private void sliderNumPartiteHomeStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sliderNumPartiteHomeStateChanged
        stateChangedSliderNumPartite(evt);

    }

    private void stateChangedSliderNumPartite(ChangeEvent evt) {
        int index = tabRiepilogoPoisson.getSelectedIndex();
        JSlider slider = (JSlider) evt.getSource();
        loadStatsTeam(getPalinsestoRowSelected(palinsestoTable), index, index == 1 ? tableIncontriHomeTeam : tableIncontriAwayTeam, tabRiepilogoPoisson.getTitleAt(index), slider.getValue());

    }//GEN-LAST:event_sliderNumPartiteHomeStateChanged

    private void formKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_formKeyPressed

        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            sliderNumPartiteHome.firePropertyChange("value", sliderNumPartiteHome.getValue(), sliderNumPartiteHome.getValue() + 1);
        }        // TODO add your handling code here:
    }//GEN-LAST:event_formKeyPressed

    private void sliderNumPartiteAwayStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sliderNumPartiteAwayStateChanged
        stateChangedSliderNumPartite(evt);
        tabRiepilogoHomeTeam.setTitleAt(0, getPalinsestoRowSelected(palinsestoTable).getHomeTeam());
        tabRiepilogoAwayTeam.setTitleAt(0, getPalinsestoRowSelected(palinsestoTable).getAwayTeam());
    }//GEN-LAST:event_sliderNumPartiteAwayStateChanged

    /**
     * @param args the command line arguments
     */

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel filtraPercentualeLabel;
    private javax.swing.JSlider filtraPercentualeSlider;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JLabel labelPerc_1;
    private javax.swing.JLabel labelPerc_12;
    private javax.swing.JLabel labelPerc_1X;
    private javax.swing.JLabel labelPerc_2;
    private javax.swing.JLabel labelPerc_Dispari;
    private javax.swing.JLabel labelPerc_Gol;
    private javax.swing.JLabel labelPerc_NoGol;
    private javax.swing.JLabel labelPerc_Pari;
    private javax.swing.JLabel labelPerc_X;
    private javax.swing.JLabel labelPerc_X2;
    private javax.swing.JLabel labelPerc_ov15;
    private javax.swing.JLabel labelPerc_ov25;
    private javax.swing.JLabel labelPerc_ov35;
    private javax.swing.JLabel labelPerc_ov45;
    private javax.swing.JLabel labelPerc_un15;
    private javax.swing.JLabel labelPerc_un25;
    private javax.swing.JLabel labelPerc_un35;
    private javax.swing.JLabel labelPerc_un45;
    private javax.swing.JLabel label_1;
    private javax.swing.JLabel label_12;
    private javax.swing.JLabel label_1X;
    private javax.swing.JLabel label_2;
    private javax.swing.JLabel label_Dispari;
    private javax.swing.JLabel label_Gol;
    private javax.swing.JLabel label_NoGol;
    private javax.swing.JLabel label_Pari;
    private javax.swing.JLabel label_X;
    private javax.swing.JLabel label_X2;
    private javax.swing.JLabel label_ov15;
    private javax.swing.JLabel label_ov25;
    private javax.swing.JLabel label_ov35;
    private javax.swing.JLabel label_ov45;
    private javax.swing.JLabel label_un15;
    private javax.swing.JLabel label_un25;
    private javax.swing.JLabel label_un35;
    private javax.swing.JLabel label_un45;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JScrollPane palinsestoScrollPane;
    private javax.swing.JTable palinsestoTable;
    private javax.swing.JPanel panel1X2;
    private javax.swing.JPanel panelPoissonScrollPane;
    private javax.swing.JPanel panelRiepilogo;
    private javax.swing.JPanel panelRiepilogoRisultati;
    private javax.swing.JPanel panelStatsAwayTeam;
    private javax.swing.JPanel panelStatsHomeTeam;
    private javax.swing.JScrollPane poissonScrollPane;
    private javax.swing.JTable poissonTable;
    private javax.swing.JScrollPane scrollPaneRiepilogoSqAway;
    private javax.swing.JScrollPane scrollPaneRiepilogoSqHome;
    private javax.swing.JScrollPane scrollPaneStatsAwayTeam;
    private javax.swing.JScrollPane scrollPaneStatsHomeTeam;
    private javax.swing.JSlider sliderNumPartiteAway;
    private javax.swing.JSlider sliderNumPartiteHome;
    private javax.swing.JSplitPane splitPane;
    private javax.swing.JSplitPane splitRiepilogo;
    private javax.swing.JTabbedPane tabRiepilogoAwayTeam;
    private javax.swing.JTabbedPane tabRiepilogoHomeTeam;
    private javax.swing.JTabbedPane tabRiepilogoPoisson;
    private javax.swing.JTable tableIncontriAwayTeam;
    private javax.swing.JTable tableIncontriHomeTeam;
    private javax.swing.JTable tableRiepilogoSqAway;
    private javax.swing.JTable tableRiepilogoSqHome;
    private javax.swing.JPanel topPanel;
    // End of variables declaration//GEN-END:variables

    private void changeSplitRiepilogoTableData() {
        try {
            Palinsesto palinsestoSelected = getPalinsestoRowSelected(palinsestoTable);
            ApplicationContext ctx = ContextSpringFactory.getInstance().getContext();
            PoissonTableModel model = ctx.getBean(PoissonTableModel.class);
            GenericService serv = ctx.getBean(GenericService.class);
            JsonTableModel modelSqHome = new JsonTableModel();
            modelSqHome.setTable(serv.findIncontroSquadraByRisultatoAndCompetizione(palinsestoSelected.getHomeTeam(), palinsestoSelected.getIdManifestazione().getDescrizioneLunga(), 10, IncontroHelper.HOME_TEAM));
            tableRiepilogoSqHome.setModel(modelSqHome);
            modelSqHome.fireTableDataChanged();
            JsonTableModel modelSqAway = new JsonTableModel();
            modelSqAway.setTable(serv.findIncontroSquadraByRisultatoAndCompetizione(palinsestoSelected.getAwayTeam(), palinsestoSelected.getIdManifestazione().getDescrizioneLunga(), 10, IncontroHelper.AWAY_TEAM));
            tableRiepilogoSqAway.setModel(modelSqAway);
            modelSqAway.fireTableDataChanged();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
